package com.book.common;

import lombok.Data;

@Data
public class Result {
    private static final String SUCCESS_CODE = "1";
    private static final String ERROR_CODE = "0";


    private String code;
    private String id;
    private String name;
    private Integer total;
    private Object data;
    private Object users;
    private Object kinds;
    private Object books;
    private String message;

    public static Result success(){
        Result result = new Result();
        result.setCode(SUCCESS_CODE);
        result.setMessage("操作成功");
        return result;
    }
    public static Result success(Object data,Integer total){
        Result result = new Result();
        result.setCode(SUCCESS_CODE);
        result.setTotal(total);
        result.setData(data);
        result.setMessage("操作成功");
        return result;
    }
    public static Result successUsers(Object users,Integer total){
        Result result = new Result();
        result.setCode(SUCCESS_CODE);
        result.setTotal(total);
        result.setUsers(users);
        result.setMessage("操作成功");
        return result;
    }
    public static Result successKinds(Object kinds,Integer total){
        Result result = new Result();
        result.setCode(SUCCESS_CODE);
        result.setTotal(total);
        result.setKinds(kinds);
        result.setMessage("操作成功");
        return result;
    }
    public static Result successBooks(Object books,Integer total){
        Result result = new Result();
        result.setCode(SUCCESS_CODE);
        result.setTotal(total);
        result.setBooks(books);
        result.setMessage("操作成功");
        return result;
    }

    public static Result successBooks1(Object books,String id,String name){
        Result result = new Result();
        result.setCode(SUCCESS_CODE);
        result.setId(id);
        result.setName(name);
        result.setBooks(books);
        result.setMessage("操作成功");
        return result;
    }

    public static Result error(String message){
        Result result = new Result();
        result.setCode(ERROR_CODE);
        result.setMessage(message);
        return result;
    }
}
